{template 'header'}
<link rel="stylesheet" href="{$siteRoot}addons/{$modular_name}/template/kindeditor/themes/default/default.css" />
<link rel="stylesheet" href="{$siteRoot}addons/{$modular_name}/template/kindeditor/plugins/code/prettify.css" />
<script charset="utf-8" src="{$siteRoot}addons/{$modular_name}/template/kindeditor/kindeditor-all.js"></script>
<script charset="utf-8" src="{$siteRoot}addons/{$modular_name}/template/kindeditor/lang/zh-CN.js"></script>
<script charset="utf-8" src="{$siteRoot}addons/{$modular_name}/template/kindeditor/plugins/code/prettify.js"></script>
<ul class="nav nav-tabs">
    <li class=""><a href="{php echo $this->createWeburl('goods');}">商品管理</a></li>
    <li class="active"><a href="{php echo $this->createWeburl('goods', array('op' => 'addshow'));}">添加商品</a></li>
    <li class=""><a href="{php echo $this->createWeburl('integralGoods')}">积分商品管理</a></li>
    <li class=""><a href="{php echo $this->createWeburl('integralGoods', array('op' => 'addshow'));}">添加积分商品</a></li>
</ul>
<form action="" method="post" class="form-horizontal" id="myform" role="form" enctype="multipart/form-data">
    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">分类:</label>
        <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">
            <select name="category_id" class="form-control">
                {loop $category $item}
                <option value="{$item['id']}" {if $item['id'] == $goods['category_id']} selected {/if}>{$item['title']}</option>
                {/loop}
            </select>
        </div>
    </div>



    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">商品名称:</label>
        <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">
            <input class="form-control" name="name" placeholder="商品名称" value="{$goods['name']}" type="text">
        </div>
    </div>


    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">分享文案:</label>
        <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">
            <input class="form-control" name="share_txt" placeholder="分享文案" value="{$goods['share_txt']}" type="text">
            <small style="color: red">  输入{name}会自动替换成昵称</small>
        </div>
    </div>

    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">原价:</label>
        <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">
            <input class="form-control" name="price" placeholder="原价" value="{$goods['price']}" type="text">
        </div>
    </div>

    <div class="form-group" id="exchange_type_money">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label" >兑换时需要多少积分:</label>
        <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">
            <input class="form-control" name="integral" placeholder="兑换时需要多少积分" value="{$goods['integral']}" type="text">
        </div>
    </div>

    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">是否是首单专享</label>
        <div class="col-sm-9 col-xs-12">
            <label class="radio-inline">
                <input type="radio" name="is_first" value="1" {if $goods['is_first'] == 1 || $goods['is_first'] == ''} checked {/if} /> 不是
            </label>
            <label class="radio-inline">
                <input type="radio" name="is_first" value="2" {if $goods['is_first'] == 2} checked {/if}/>是
            </label>
        </div>
    </div>

    <div class="form-group" id="ling-1">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">封面图:</label>
        <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">
            {php echo tpl_form_field_image('cover_image',  $goods['cover_image'],  tomedia($goods['cover_image']));}
            <small style="color: red">图片大小建议为 : 170 * 170</small>
        </div>
    </div>

    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">详情:</label>
        <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">
            {php echo tpl_form_field_multi_image('images',$goods['images']);}
            <small style="color: red">图片大小建议为: 410 * 400</small>
        </div>
    </div>

    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">库存:</label>
        <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">
            <input class="form-control" name="stock" placeholder="库存" value="{$goods['stock']}" type="text">
        </div>
    </div>


    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">是否包邮</label>
        <div class="col-sm-9 col-xs-12">
            <label class="radio-inline">
                <input type="radio" name="is_free" value="1" {if $goods['is_free'] ==1 || $goods['is_free'] == ''} checked {/if} /> 包邮
            </label>
            <label class="radio-inline">
                <input type="radio" name="is_free" value="2" {if $goods['is_free'] ==2} checked {/if}/>不包邮
            </label>
        </div>
    </div>

    <div class="form-group" id="is_free_money" {if $goods['is_free'] != 2 } style="display: none" {/if} >
    <label class="col-xs-12 col-sm-3 col-md-1 control-label">邮费:</label>
    <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">
        <input class="form-control" name="free" placeholder="邮费" value="{$goods['free']}" type="text">
    </div>
    </div>
    <div class="form-group" id="compiler" >
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">详情:</label>
        <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12" style="padding-top:8px;">
            <textarea name="details" style="width:1000px;height:400px;visibility:hidden;">{$goods['details']}</textarea>
        </div>
        <script>
            KindEditor.ready(function(K) {
                htmlEditor = K.create(
                    'textarea[name="details"]',
                    {
                        uploadJson : "{php echo $this->createWebUrl('editorUpload');}",
                        fileManagerJson : '{$siteRoot}addons/{$modular_name}/template/kindeditor/php/file_manager_json.php',
                        height : 300,
                        width : '90%',
                        resizeType : 0,//1
                        allowPreviewEmoticons : true,
                        allowImageUpload : true,
                        urlType:'domain',
                        formatUploadUrl:false
                    });
            });
        </script>
    </div>
    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">砍价完成多少金额后,进入砍价后期:</label>
        <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">
            <input class="form-control" name="in_after" placeholder="砍价完成多少金额后,进入砍价后期" value="{$goods['in_after']}" type="text">
            <small style="color: red"> 这儿填写金额，砍了多少进入后期 例如，你价格是199 ，这儿填写 99 那么就是砍价99后进入后期</small>
        </div>
    </div>


    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">砍价前期<small style="color: red">老</small>用户砍价范围:</label>
        <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12" style="float: left">
            <input class="form-control" name="old_start"  style="width:20%;float: left"  placeholder="砍价前期老用户砍价最少值" value="{$goods['old_start']}" type="text">
            <input class="form-control" name="old_end"   style="width:20%;float: left" placeholder="砍价前期老用户砍价最多值" value="{$goods['old_end']}" type="text">
        </div>
    </div>


    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">砍价前期<small style="color: red">新</small>用户砍价范围:</label>
        <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12" style="float: left">
            <input class="form-control" name="new_start"  style="width:20%;float: left"  placeholder="砍价前期新用户砍价最少值" value="{$goods['new_start']}" type="text">
            <input class="form-control" name="new_end"  style="width:20%;float: left"  placeholder="砍价前期新用户砍价最多值" value="{$goods['new_end']}" type="text">
        </div>
    </div>

    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">砍价后期<small style="color: red">老</small>用户砍价范围:</label>
        <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12" style="float: left">
            <input class="form-control" name="old_after_start"  style="width:20%;float: left"  placeholder="砍价后期老用户砍价最少值" value="{$goods['old_after_start']}" type="text">
            <input class="form-control" name="old_after_end"  style="width:20%;float: left"  placeholder="砍价后期老用户砍价最多值" value="{$goods['old_after_end']}" type="text">
        </div>
    </div>


    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">砍价后期<small style="color: red">新</small>用户砍价范围:</label>
        <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12" style="float: left">
            <input class="form-control" name="new_after_start"  style="width:20%;float: left"  placeholder="砍价后期新用户砍价最少值" value="{$goods['new_after_start']}" type="text">
            <input class="form-control" name="new_after_end"   style="width:20%;float: left"  placeholder="砍价后期新用户砍价最多值" value="{$goods['new_after_end']}" type="text">
        </div>
    </div>

    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">自己<small style="color: red">砍价</small>范围:</label>
        <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12" style="float: left">
            <input class="form-control" name="own_start"  style="width:20%;float: left"  placeholder="自己砍价最少值" value="{$goods['own_start']}" type="text">
            <input class="form-control" name="own_end"   style="width:20%;float: left"  placeholder="自己砍价最多值" value="{$goods['own_end']}" type="text">
        </div>
    </div>

    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">可以砍价时间:</label>
        <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">
            <input class="form-control" name="bargain_time" placeholder="可以砍价时间" value="{$goods['bargain_time']}" type="text">
            <small style="color: red"> 填写时间 单位多少秒 开始后可以砍多少时间</small>
        </div>
    </div>
    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">上下架</label>
        <div class="col-sm-9 col-xs-12">
            <label class="radio-inline">
                <input type="radio" name="status" value="1" {if $goods['status'] ==1 || $goods['status'] == ''} checked {/if} /> 上架
            </label>
            <label class="radio-inline">
                <input type="radio" name="status" value="2" {if $goods['status'] ==2} checked {/if}/>下架
            </label>
        </div>
    </div>
    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">是否首页显示</label>
        <div class="col-sm-9 col-xs-12">
            <label class="radio-inline">
                <input type="radio" name="is_home" value="1" {if $goods['is_home'] ==1 || $goods['is_home'] == ''} checked {/if} /> 不显示
            </label>
            <label class="radio-inline">
                <input type="radio" name="is_home" value="2" {if $goods['is_home'] ==2} checked {/if}/>显示
            </label>
        </div>
    </div>
    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">顺序:</label>
        <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">
            <input class="form-control" name="sort" placeholder="顺序" value="{$goods['sort']}" type="text">
        </div>
    </div>


    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label"></label>
        <div class="" >
            <input type="hidden" name="op" value="{php echo $id ? 'edit' : 'add'}">
            <input type="hidden" name="id" value="{$id}">
            <input type="submit" name="submit" id="submit" value="{php echo $id ? '修改' : '新增'}" class="btn btn-primary">
        </div>
    </div>
</form>
{template 'footer'}


<script>
    $(function () {
        $("input[name='exchange_type']").click(function () {
            if ( $(this).val() == 1) {
                $('#exchange_type_money').show();
                $('#money').hide();
            }  else {
                $('#exchange_type_money').show();
                $('#money').show();
            }
        });


        $("input[name='is_free']").click(function () {
            if ( $(this).val() == 1) {
                $('#is_free_money').hide();
            }  else {
                $('#is_free_money').show();
            }
        });

        $("input[name='type']").click(function () {
            if ( $(this).val() == 1) {
                $('#bag_money').hide();
                $('#fabulous').hide();
            }  else if($(this).val() ==2){
                $('#bag_money').show();
                $('#fabulous').hide();
            } else {
                $('#bag_money').hide();
                $('#fabulous').show();
            }
        });

    })


</script>